package com.model;

/**
 * Created by LPFma on 2016/12/4 0004.
 */
public class UserRegisterModel {
    public static String isUsernameValid(String username) {
        if (username.length() > 20) {
            return "invalid";
        }

        for (int i = 0; i < username.length(); ++i) {
            char ch = username.charAt(i);
            if (!(ch >= '0' && ch <= '9'
                    || ch >= 'a' && ch <= 'z'
                    || ch >= 'A' && ch <= 'Z'
                    || ch == '@')){
                return "invalid";
            }
        }

        return "valid";
    }

    public static String isPasswdValid(String passwd) {
        if (passwd.length() < 6 || passwd.length() > 16) {
            return "invalid";
        }

        for (int i = 0; i < passwd.length(); ++i) {
            char ch = passwd.charAt(i);
            if (!(ch >= '0' && ch <= '9'
                    || ch >= 'a' && ch <= 'z'
                    || ch >= 'A' && ch <= 'Z')){
                return "invalid";
            }
        }

        return "valid";
    }
}
